package com.example.mobile203zlw20216061300521;

import android.content.Context;
import android.service.autofill.TextValueSanitizer;
import android.view.LayoutInflater;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.text.Normalizer;
import java.util.List;
import java.util.zip.Inflater;

public class Adapter extends RecyclerView.Adapter<Adapter.main_adapter> {
    private List<NEWS>list;
    public Adapter(List<NEWS> list) {
        this.list = list;
    }

    @NonNull
    @Override
    public main_adapter onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.main_adapter,parent,false);
        return new main_adapter(view);
    }

    @Override
    public void onBindViewHolder(@NonNull main_adapter holder, int position) {
        NEWS news=list.get(position);
        holder._id.setText(String.valueOf(news.getId()));
        holder._tital.setText(String.valueOf(news.getTitle()));
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class main_adapter extends RecyclerView.ViewHolder {
          private   TextView _id,_tital ;
        public main_adapter(@NonNull View itemView) {
            super(itemView);
            _id=itemView.findViewById(R.id._id);
            _tital=itemView.findViewById(R.id._title);
        }
    }
}
